import messageBox from "./messageBox.vue";
import Vue from "vue";


const messageBoxConstructor = Vue.extend(messageBox);

function showMessage(message, mode = "alert", customize){
    return new Promise((res) => {
        const messageBoxDom = new messageBoxConstructor({
            el: document.createElement('div')
        });
        document.body.appendChild(messageBoxDom.$el);
        messageBoxDom.message = message;
        messageBoxDom.mode = mode;
        messageBoxDom.customize = customize;
        messageBoxDom.ok = function(){
            messageBoxDom.$el.remove();
            res("ok");
        }
        messageBoxDom.cancel = function(){
            messageBoxDom.$el.remove();
            res("cancel");
        }
        messageBoxDom.clickButton = function(command){
            messageBoxDom.$el.remove();
            res(command);
        }
    });
}




export default showMessage;
